<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/jsp/struts/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="./style/alternative.css" media="all" rel="stylesheet" />
<style type="text/css">
#roleDiv {
    padding-left:2em;
    padding-top:2em;
    font-size: 1em
}
.submodule {
    list-style-type: none;
}
.submodule a {
    font-size: 1.1em
}
</style>
<script type='text/javascript' src='script/prototype.js'></script>
<script type='text/javascript' src='script/common.js'></script>
<SCRIPT LANGUAGE="JavaScript">
function changeRole()
{
    var oRole = document.getElementById("roleID");
    var roleID =oRole.options[oRole.selectedIndex].value;
    location.replace("role.htm?method=retrieve&roleID="+roleID);

}

function checkForm() {
    var strModuleID = "";
    $$('input[type="checkbox"][name="moduleID"]').select(function(i){return i.checked}).each(function(i)
    {
       strModuleID = strModuleID + " " + i.value;
    });  

    $("strModuleID").value=strModuleID;
    //alert("strModuleID=" + strModuleID);
    
}
function submitForm(method) {
	if(method=="save") {
	    if(""=="${role.roleName}")
	    	$("method").value="create";
	    else 
    	    $("method").value="update";
	} else {
	    $("method").value=method;
	}
	checkForm();
	$("roleForm").submit();

}
<c:if test="${empty role}">
window.onload = function(){
    onNone();
}
</c:if>
</script>
</head>
<body>
<c:choose>
<c:when test="${empty role}">
<c:set var="handler" value="role.htm?method=create" />
</c:when>
<c:otherwise>
<c:set var="handler" value="role.htm?method=update" />
</c:otherwise>
</c:choose>
<div id="content">
    <div id="content_inner">
<FORM METHOD="post" name="roleForm" id="roleForm" ACTION="${handler}">
<div id="roleDiv">
<TABLE id="roleTab" class="its">
<thead>
  <TR>
    <TH colspan="2" align="center">角色</TH>
  </TR>
  </thead>
  <TR>
    <TD>角色名称:</TD>
    <TD>
    <input type="text" NAME="roleName" id="roleName" size="50" value="${role.roleName}">
    </TD>
  </TR>
  <TR>
    <TD>描述:</TD>
    <TD>
    <input type="text"  NAME="description" id="description" size="50" value="${role.description}">
    </TD>
  </TR>
  <TR>
    <TD  valign="top">相关模块: </TD>
    <TD>
<div id="modules">
<c:choose>
<c:when test="${empty role}">
<c:set var="moduleList" value="${allModuleList}"/>
</c:when>
<c:otherwise>
<c:set var="moduleList" value="${role.moduleList}"/>
</c:otherwise>
</c:choose>
<ul>
<c:forEach items="${moduleList}" var="module" varStatus="moduleNum">
<li><INPUT TYPE="checkbox" ID="moduleID" NAME="moduleID"
value="${module.moduleID}" 
<c:if test="${module.moduleStatus > 0}">
checked="true"
</c:if> > 
<span title="${module.moduleID}. ${module.description}">
<a href="module.htm?method=retrieve&moduleID=${module.moduleID}">${module.moduleName}
</a></span>
<ul class="submodule">
<c:forEach items="${module.subModuleList}" var="subModule" varStatus="subModuleNum">
<li><INPUT TYPE="checkbox" ID="moduleID" NAME="moduleID"
value="${subModule.moduleID}" 
<c:if test="${subModule.moduleStatus > 0}">
checked="true"
</c:if> > 
<span title="${subModule.moduleID}. ${subModule.moduleName}">
<a href="module.htm?method=retrieve&moduleID=${subModule.moduleID}">
${subModule.description}</a></span>
: 
<c:forEach items="${module.functionList}" var="function" varStatus="functionNum">
${function.functionName} 
</c:forEach>
</c:forEach>
</ul>
</c:forEach>
</ul>
</div><!-- modules -->    
    </TD>
  </TR>
  <TR>
<TD>
<input type="hidden" name="method" id="method">
<input type="hidden" name="strModuleID" id="strModuleID">
<input type="hidden" name="roleID" id="roleID" value="${role.roleID}">
</TD>
<TD>
<INPUT TYPE="checkbox" name="checkAllBox" id="checkAllBox" onclick="checkAll('checkAllBox')">
<INPUT TYPE="button" name="action" onclick="submitForm('save')" value="保存 ">
<INPUT TYPE="button" name="action" onclick="submitForm('delete')" value="删除 ">
<INPUT TYPE="button" name="action" onclick="javascript:history.back()" value="取消 ">
</TR>
  </TABLE>
</div>
<br>
</form>
</div><!-- content_inner -->
</div><!-- content -->
